package test;

import heap.ResultSchema;

import java.rmi.RemoteException;
import java.sql.*;

import SQL.scan.Scan;

import rmi.RemoteConnection;
import rmi.RemoteConnectionImpl;
import rmi.RemoteResultSet;
import rmi.RemoteResultSetImpl;
import rmi.RemoteStatement;
import rmi.RemoteStatementImpl;
import jdbcinterface.GoggleConnection;
import jdbcinterface.GoggleDriver;
import jdbcinterface.GoggleResultSet;
import jdbcinterface.GoggleStatement;

public class Main {
	public static void main(String args[])
	{
		RemoteConnection c;
		try {
			Driver driver=new GoggleDriver();
			Connection connection=driver.connect("jdbc:goggle://localhost/goggle", null);
			Statement statement=connection.createStatement();
//			statement.execute("CREATE DATABASE goggle");
	//		statement.execute("CREATE TABLE t2 (s1 INT)");
			statement.execute("INSERT INTO t2 VALUES (2)");
		//	statement.execute("CREATE TABLE t4 (s1 INT,s2 INT,s3 INT)");
			//statement.execute("INSERT INTO t3 VALUES (2)");
			statement.execute("InsERT INTO t4 VALUES (1,2,3)");
			statement.execute("InsERT INTO t4 VALUES (2,2,3)");
//			statement.execute("InsERT INTO t4 VALUES (3,2,3)");
//			statement.execute("InsERT INTO t4 VALUES (4,2,3)");
//			statement.execute("InsERT INTO t4 VALUES (5,2,3)");
//			statement.execute("InsERT INTO t4 VALUES (9,2,3)");
			statement.execute("UPDATE t4 SET s1=9");
			PreparedStatement sta=connection.prepareStatement("UPDATE t4 SET s1=9");
			sta.execute();
			ResultSet set = statement.executeQuery("SELECT * FROM t4");
			int i=1;
			while (set.next())
			{
				ResultSetMetaData metaData=set.getMetaData();
				System.out.println(metaData.getColumnName(1));
				System.out.println(set.getString(1));
				//System.out.println(set.getString(1)+" "+set.getString(2) +" "+set.getString(3));
			}
//			statement.close();
			
			connection.close();
		//	RemoteStatement statement=new RemoteStatementImpl(new RemoteConnectionImpl("testDB"));
		//	GoggleStatement statement2=new GoggleStatement(statement);
			//statement2.execute("CREATE TABLE t1 (s1 INT)");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			
		}
		
	}
}
